package cn.okcode.slowjson.ast;

import cn.okcode.slowjson.parser.Serializer;
import cn.okcode.slowjson.parser.Visitor;

/**
 * @author pyk13
 */
public class StringNode extends AbstractNode<String> {
    private final String value;
    private final boolean property;

    public StringNode(String value) {
        this(value, false);
    }

    public StringNode(String value, boolean property) {
        this.value = value;
        this.property = property;
    }

    @Override
    public String getValue() {
        return value;
    }

    @Override
    public String stringValue() {
        return "\"" + Serializer.serializeString(value) + "\"";
    }

    @Override
    public void accept(Visitor visitor) {
        visitor.visit(this);
    }

    public boolean isProperty() {
        return property;
    }
}
